home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
print
/
gs261ini.zip
/
GS_FONTS.PS
< prev
next >
Wrap
Text File
|
1993-05-27
|
18KB
|
538 lines
% Copyright (C) 1990, 1992, 1993 Aladdin Enterprises. All rights reserved.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% copies.
% Font initialization for Ghostscript.
% The standard representation for PostScript compatible fonts is described
% in the book "Adobe Type 1 Font Format", published by Adobe Systems Inc.
% We don't attempt to document this representation here.
% Ghostscript uses Type 1 fonts, except that the external form doesn't use
% eexec encryption and may not even use CharString encryption.
% Define the default font.
/defaultfontname /Ugly def
% Load the font name -> font file name map.
userdict /Fontmap FontDirectory maxlength dict put
/.loadFontmap % <filename>
{ 2 dict begin
mark Fontmap
/;
{ % The stack contains a mark, the dictionary, the font name,
% the file or alias name, and possibly additional information
% about the font.
counttomark 3 sub { pop } repeat .growput
Fontmap
} bind def
3 -1 roll run
end
pop pop % pop the mark and the copy of the dictionary
} bind def
(Fontmap) .loadFontmap
% Ghostscript optionally can load individual CharStrings as they are needed.
% (This is intended primarily for machines with very small memories.)
% This happens if DISKFONTS is true. In this case, we define another
% dictionary parallel to FontDirectory that retains an open file
% for every font loaded.
/FontFileDirectory 10 dict def
% Define an augmented version of .buildfont1 that inserts UnderlinePosition
% and UnderlineThickness entries in FontInfo if they aren't there already.
% (This works around the incorrect assumption, made by many word processors,
% that these entries are present in the built-in fonts.)
/.buildfont1x
{ dup /FontInfo known not
{ dup /FontInfo 2 dict .growput }
if
dup dup /FontInfo get dup dup
/UnderlinePosition known exch /UnderlineThickness known and
{ pop pop % entries already present
}
{ dup length 2 add dict copy
dup /UnderlinePosition known not
{ dup /UnderlinePosition 3 index /FontBBox get
1 get 2 div put % 1/2 the font descent
}
if
dup /UnderlineThickness known not
{ dup /UnderlineThickness 3 index /FontBBox get
dup 3 get exch 1 get sub 20 div put % 1/20 the font height
}
if
1 index /FontInfo get wcheck not { readonly } if
/FontInfo exch put
}
ifelse .buildfont1
} bind def
% Define definefont. This is a procedure built on a set of operators
% that do all the error checking and key insertion.
mark
/.buildfont0 where { pop 0 /.buildfont0 load } if
/.buildfont1 where { pop 1 /.buildfont1x load } if
/.buildfont3 where { pop 3 /.buildfont3 load } if
.dicttomark /.buildfontdict exch def
/definefont
{ 1 dict begin count /d exch def % save stack depth in case of error
{ % Check for disabled platform fonts.
NOPLATFONTS
{ dup maxlength 1 index length sub 2 lt { dup .growdict } if
dup /ExactSize 0 put
}
{ % Hack: if the Encoding looks like it might be the
% Symbol or Dingbats encoding, load those now (for the
% benefit of platform font matching) just in case
% the font didn't actually reference them.
dup /Encoding get length 65 ge
{ dup /Encoding get 64 get
dup /congruent eq { SymbolEncoding pop } if
/a9 eq { DingbatsEncoding pop } if
}
if
}
ifelse
dup /FontType get //.buildfontdict exch get exec
DISKFONTS
{ FontFileDirectory 2 index known
{ dup /FontFile FontFileDirectory 4 index get .growput
}
if
}
if
readonly
}
stopped
{ count d sub { pop } repeat end /invalidfont signalerror }
{ end dup FontDirectory 4 2 roll .growput }
ifelse
} odef
% Ghostscript optionally can load individual CharStrings as they are needed.
% (This is intended primarily for machines with very small memories.)
% Initially, the character definition is the file position of the definition;
% this gets replaced with the actual CharString.
% Note that if we are loading characters lazily, CharStrings is writable.
% _Cstring must be long enough to hold the longest CharString for
% a character defined using seac. This is lenIV + 4 * 5 (for the operands
% of sbw, assuming div is not used) + 2 (for sbw) + 3 * 5 (for the operands
% of seac other than the character codes) + 2 * 2 (for the character codes)
% + 2 (for seac), i.e., lenIV + 43.
/_Cstring 60 string def
% When we initially load the font, we call
% <index|charname> <length> <readproc> cskip_C
% to skip over each character definition and return the file position instead.
% This substitutes for the procedure
% <index|charname> <length> string currentfile exch read[hex]string pop
% [encrypt]
% What we actually store is fileposition * 1000 + length,
% negated if the string is stored in binary form.
% Older fonts use skip_C rather than cskip_C.
% skip_C takes /readstring or /readhexstring as its third argument,
% instead of the entire reading procedure.
/skipproc_C {string currentfile exch readstring pop} cvlit def
/skip_C
{ //skipproc_C dup 3 4 -1 roll put cvx readonly cskip_C
} bind def
/cskip_C
{ exch dup 1000 ge 3 index type /nametype ne or
{ % This is a Subrs string, or the string is so long we can't represent
% its length. Load it now.
exch exec
}
{ % Record the position and length, and skip the string.
dup currentfile fileposition 1000 mul add
2 index 3 get /readstring cvx eq { neg } if
3 1 roll
dup _Cstring length idiv
{ currentfile _Cstring 3 index 3 get exec pop pop
} repeat
_Cstring length mod _Cstring exch 0 exch getinterval
currentfile exch 3 -1 roll 3 get exec pop pop
}
ifelse
} bind def
% Type1BuildGlyph calls load_C to actually load the character definition.
/load_C % <charname> <fileposandlength> -> -
{ dup abs 1000 idiv FontFile exch setfileposition
CharStrings 3 1 roll
dup 0 lt
{ neg 1000 mod string FontFile exch readstring }
{ 1000 mod string FontFile exch readhexstring }
ifelse pop
% If the CharStrings aren't encrypted on the file, encrypt now.
Private /-| get 0 get
dup type /nametype ne { dup length 5 sub 5 exch getinterval exec } { pop } ifelse
dup 4 1 roll put
% If the character is defined with seac, load its components now.
mark exch seac_C
counttomark
{ StandardEncoding exch get dup CharStrings exch get
dup type /integertype eq { load_C } { pop pop } ifelse
} repeat
pop % the mark
} bind def
/seac_C % charstring -> achar bchar ..or nothing..
{ dup length _Cstring length le
{ 4330 exch _Cstring .type1decrypt exch pop
dup dup length 2 sub 2 getinterval <0c06> eq % seac
{ dup length
Private /lenIV known { Private /lenIV get } { 4 } ifelse
exch 1 index sub getinterval
% Parse the string just enough to extract the seac information.
% We assume that the only possible operators are hsbw, sbw, and seac,
% and that there are no 5-byte numbers.
mark 0 3 -1 roll
{ exch
{ { dup 32 lt
{ pop 0 }
{ dup 247 lt
{ 139 sub 0 }
{ dup 251 lt
{ 247 sub 256 mul 108 add 1